| Conditions | 3 |
| Total Lines | 23 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { QueryHandler } from '@nestjs/cqrs'; |
||
| 18 | |||
| 19 | public async execute(query: UserLoginQuery): Promise<UserView> { |
||
| 20 | const email = query.email.toLowerCase(); |
||
| 21 | const user = await this.userRepository.findOneByEmail(email); |
||
| 22 | |||
| 23 | if (!user) { |
||
| 24 | throw new UserNotFoundException(); |
||
| 25 | } |
||
| 26 | |||
| 27 | if ( |
||
| 28 | false === |
||
| 29 | (await this.passwordEncoder.compare(user.getPassword(), query.password)) |
||
| 30 | ) { |
||
| 31 | throw new PasswordNotMatchException(); |
||
| 32 | } |
||
| 33 | |||
| 34 | return new UserView( |
||
| 35 | user.getId(), |
||
| 36 | user.getFirstName(), |
||
| 37 | user.getLastName(), |
||
| 38 | user.getEmail(), |
||
| 39 | user.getRole(), |
||
| 40 | user.getApiToken() |
||
| 41 | ); |
||
| 44 |